<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>反转链表</title>
</head>
<body>
<script type="text/javascript" src="./js/LinkedList1.js"></script>
<script type="text/javascript">
function ReverseList(pHead) {
    // write code here
    console.log(pHead);
    let prev = null;
    while(pHead) {
        let curr = pHead;
        pHead = pHead.next;
        curr.next = prev;
        //pHead 的值为 11,12,13,14 的话
        //prev 的次依次是:(11),(12,11),(13,12,11),(14,13,12,11)
        prev = curr;
    }
    return prev;
}
var obj = new LinkedList();
obj.addAtHead(11);
obj.addAtTail(12);
obj.addAtTail(13);
obj.addAtTail(14);
ReverseList(obj.head);
console.log(obj.toString());
</script>
</body>
</html>